package com.qianfeng.dbsm.controller;

import com.qianfeng.dbsm.service.TotalService;
import com.qianfeng.dbsm.service.TestService;
import com.qianfeng.dbsm.vo.OrderVo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/statistics")
public class StatisticsController {
    //接口调用测试
    @Autowired
    private TestService testService;
    @ApiOperation(value = "测试", notes = "测试说明")
    @GetMapping("/test")
    public List<OrderVo> test(){
        return testService.Test();
    }

    @Autowired
    private TotalService totalService;

    @ApiOperation(value = "总销售额", notes = "查询；通过订单状态查询订单状态之后的订单总销售额；5 为签收后的订单状态；输入订单状态，输出总销售额")
    @GetMapping("/queryByTotalSales")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "orderState",value = "订单状态",dataType = "int"),
    })
    public double queryByTotalSales(int orderState){
        return totalService.queryByTotalSales(orderState);
    }

    @ApiOperation(value = "总销售量", notes = "查询；通过订单状态查询输入订单状态之后的订单总销量；5 为签收后的订单状态；输入订单状态；输出订单总销量")
    @GetMapping("/queryByTotalSalesVolume")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "orderState",value = "订单状态",dataType = "int"),
    })
    public int queryByTotalSalesVolume(int orderState){
        return totalService.queryByTotalSalesVolume(orderState);
    }
}